<template>
  <div class="shop_control">
    <!-- 头部 -->
    <div class="top">
      <div class="content">
        <div class="nav">
          <div></div>
          <p>商品管理</p>
        </div>
        <div class="top_btn">
          <el-button icon="el-icon-refresh" size="small" @click="refresh"
            >刷新</el-button
          >
          <el-button icon="el-icon-arrow-left" size="small">返回</el-button>
        </div>
      </div>
    </div>
    <!-- 数据筛选 -->
    <el-card class="box-card" shadow="never">
      <div slot="header" class="clearfix">
        <span>数据筛选</span>
      </div>
      <div class="content_box">
        <div class="child_box">
          商品名称：<el-input
            v-model="shopName"
            placeholder="商品名称"
            size="medium"
            class="input_box"
          ></el-input>
        </div>
        <div class="child_box">
          商品类型：<el-select
            v-model="shopType"
            filterable
            placeholder="全部"
            size="medium"
          >
            <el-option
              v-for="item in shopTypeOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
        <div class="child_box">
          商品状态：<el-select
            v-model="shopState"
            filterable
            placeholder="全部"
            size="medium"
          >
            <el-option
              v-for="item in shopStateOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
        <el-button type="primary" icon="el-icon-search" size="medium"
          >查询</el-button
        >
      </div>
    </el-card>
    <!-- 数据列表 -->
    <el-card class="box-card">
      <div class="clearfix">
        <span>数据列表</span>
        <el-button style="float: right; padding: 3px 0" type="text" @click="addShop"
          >添加商品</el-button
        >
      </div>
      <div class="data_list">
        <el-table
          :data="tableData"
          style="width: 100%"
          border
          :header-cell-style="{ background: '#f5f5f5' }"
        >
          <el-table-column prop="date" label="编号" width="150">
          </el-table-column>
          <el-table-column prop="name" label="商品名称" width="120">
          </el-table-column>
          <el-table-column prop="province" label="所属商铺" width="120">
          </el-table-column>
          <el-table-column prop="city" label="价格（元）" width="120">
          </el-table-column>
          <el-table-column prop="address" label="单位" width="300">
          </el-table-column>
          <el-table-column prop="zip" label="库存" width="120">
          </el-table-column>
          <el-table-column prop="zip" label="库存预警值" width="120">
          </el-table-column>
          <el-table-column prop="zip" label="商品状态" width="120">
          </el-table-column>
          <el-table-column label="操作" width="300">
            <template slot-scope="scope">
              <el-button
                @click="handleClick(scope.row)"
                type="text"
                size="small"
                >查看</el-button
              >
              <el-button type="text" size="small">编辑</el-button>
              <el-button
                @click="handleClick(scope.row)"
                type="text"
                size="small"
                >入库</el-button
              >
              <el-button type="text" size="small">上架</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="10"
          layout=" prev, pager, next,sizes"
          :total="500"
        >
          >
        </el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "shop_control",
  data() {
    return {
      //商品名称
      shopName: "",
      //商品状态
      shopState: "",
      //商品类型
      shopType: "",
      //数据列表数据
      tableData: [
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
      ],
      currentPage: 1,
      //类型下拉框选项
      shopTypeOptions: [
        {
          value: "选项1",
          label: "全部",
        },
        {
          value: "选项2",
          label: "全部产品",
        },
        {
          value: "选项3",
          label: "附属产品",
        },
      ],
      shopStateOptions: [
        {
          value: "选项1",
          label: "全部",
        },
        {
          value: "选项2",
          label: "已上架",
        },
        {
          value: "选项3",
          label: "已下架",
        },
      ],
    };
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    handleClick(row) {
      console.log(row);
      this.$router.push("/shopInfo");
    },
    // 刷新页面
    refresh() {
      this.$router.go(0);
    },
    //添加商品
    addShop() {
      this.$router.push("/add_shop"); 
     }
  },
};
</script>

<style lang="scss" scoped>
.shop_control {
  background-color: #f5f5f5;
  height: 100%;
  width: 100%;
}
//头部
.top {
  height: 50px;
  width: 100%;
  margin: 0 auto;
  background-color: #f3f3f3;
  border-bottom: 2px solid #e4e4e4;
  .content {
    margin: 0 auto;
    width: 1260px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .nav {
      width: 50%;
      height: 50%;
      display: flex;
      div {
        width: 3px;
        height: 100%;
        background-color: #00bfa0;
      }
      p {
        margin-left: 10px;
        height: 100%;
        line-height: 25px;
        font-size: 14px;
        color: #999999;
      }
    }
    .top_btn {
      width: 50%;
      text-align: right;
      .el-button {
        margin: 0;
        border-radius: 0;
        height: 50%;
      }
    }
  }
}
//数据筛选
.box-card {
  width: 1280px;
  margin: 0 auto;
  margin-top: 30px;
  border-radius: 0;
}
.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}
.content_box {
  display: flex;
  justify-content: space-around;
  align-items: center;

  .child_box {
    width: 40%;
    height: 50%;
    display: flex;
    white-space: nowrap;
    line-height: 200%;
    .input_box {
      width: 65%;
    }
  }
}
// 分页
.el-pagination {
  margin: 20px 0;
  float: right;
}
</style>